//
//  SearchAddressCell.swift
//  GreenDeal
//
//  Created by Moennig Q on 27/2/2023.
//

import UIKit

class SearchAddressDictionaryCell: UITableViewCell {
    
    var titleLabel: BaseLabel!
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setUpviews()
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        if selected {
            self.contentView.backgroundColor = UIColor(hexStr: "#E7F9F2")
        }else {
            self.contentView.backgroundColor = UIColor.white
        }
    }
    private func setUpviews(){
        self.selectionStyle = .none
        //model
        titleLabel = ContentLabel(R.font.interMedium(size: 15))
        titleLabel.numberOfLines = 2
        titleLabel.textAlignment = .left
        self.contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(12)
            make.left.equalTo(16)
            make.right.equalTo(-16)
            make.bottom.equalTo(-12)
            make.height.greaterThanOrEqualTo(0)
        }
    }
    func setData(_ model: PhysicalAddressViewModel, type: SearchAddressDictionaryType){
        switch type {
        case .postcode:
            self.titleLabel.text = model.post_code_display_name
        case .unitType:
            self.titleLabel.text = model.unit_type_name
        case .streetType:
            self.titleLabel.text = model.street_type_name
        }
    }
}
